package master;

/**
 * @author chenyw
 * @date 2022/7/25 16:59
 */
public class M58lengthOfLastWord {
    public int lengthOfLastWord(String s) {
        s = s.trim();
        int count = 0;
        for (int i = s.length() - 1; i >= 0; i--) {
            if (s.charAt(i) == ' ') {
                break;
            }
            count++;
        }
        return count;
    }
}
